﻿using qcloudsms_csharp;
using qcloudsms_csharp.httpclient;
using qcloudsms_csharp.json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZhouYu.DreamTour.WinService.AuditPassSMS
{
    public class TenXunYunSmSForAuditPass   //用于提现审核通知
    {
        //appId
        public int appId= 1400271368;
        //appKey
        public string appKey = "ea4339dd9d7f05bacfa64340aa68b370";
        //短信模板ID
        private int tmplateId = 495215;
        //签名内容
        private string smsSign = "码农网";
        /// <summary>
        /// 验证码
        /// </summary>
        public int Code { get; set; }
        /// <summary>
        /// 发送验证码
        /// </summary>
        /// <param name="phone"></param>
        /// <returns></returns>
        public void SetSMS(string phone, string userName, decimal money,string bankNum,string type)
        {
            try
            {
                SmsSingleSender ssender = new SmsSingleSender(appId, appKey);
                var result = ssender.sendWithParam("86", phone,
                    tmplateId, new[] { userName, money.ToString(), bankNum, type }, smsSign, "", "");  // 签名参数未提供或者为空时，会使用默认签名发送短信
            }
            catch (JSONException ex)
            {
                File.AppendAllText("D:\\Ex.txt", ex.ToString());
                throw;
            }
            catch (HTTPException ex)
            {
                File.AppendAllText("D:\\Ex.txt", ex.ToString());
                throw;
            }
            catch (Exception ex)
            {
                File.AppendAllText("D:\\Ex.txt", ex.ToString());
                throw;
            }
        }
    }
}
